<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:a4j="http://richfaces.org/a4j"
	xmlns:rich="http://richfaces.org/rich"
	xmlns:c="http://java.sun.com/jstl/core"
	xmlns:p="http://primefaces.prime.com.tr/ui">

		<p:panel>
			<p:messages globalOnly="true" rendered="true"/>
				<f:facet name="header">
					<h:outputText value="#{msg.sala}" />
				</f:facet>
				<rich:tabPanel>
				<!-- TAB 1 Sala -->
				<rich:tab label="#{msg.principal}" switchType="client">
					<h:form id="idSalaMBForm">	
						<fieldset id="legend_area"><legend id="legend">
						<h:outputLabel value="#{msg.salaDados}" /></legend> 
							<h:panelGrid columns="2">
								<h:panelGroup>
									<br/>
									<h:outputLabel value="#{msg.nome}" for="idNomeSala" />
									<span class="req"> *</span>
								</h:panelGroup>
								<h:panelGroup>
									<rich:message for="idNomeSala" styleClass="mensagem_erro_campo" /><br/>
									<h:inputHidden value="#{salaMB.sala.id}"/>
									<h:inputText id="idNomeSala"
										value="#{salaMB.sala.nome}" size="25" maxlength="25"
										onkeyup="javascript:toUpperCase(this);" required="true"
										requiredMessage="#{msg.campoObrigatorio}">
										<rich:ajaxValidator event="onblur" />
									</h:inputText>
								</h:panelGroup>
		
								<h:panelGroup>
									<br/>
									<h:outputLabel value="#{msg.identificacao}" for="idIdentificacaoSala" />
								</h:panelGroup>
								<h:panelGroup>
									<br/>
									<h:inputText id="idIdentificacaoSala"
										value="#{salaMB.sala.identificacao}" size="45" maxlength="45"
										onkeyup="javascript:toUpperCase(this);">
									</h:inputText>
								</h:panelGroup>
				
								<h:panelGroup>
									<br/>
									<h:outputLabel value="#{msg.setor}" for="idSetorSala" /><span class="req"> *</span>
								</h:panelGroup>
								<h:panelGroup>
									<rich:message for="idSetorSala" styleClass="mensagem_erro_campo"/>
									<rich:comboBox id="idSetorSala" defaultLabel="#{msg.escolhaOpcao}" width="250"
									 	value="#{salaMB.sala.setor.nome}" required="true" requiredMessage="#{msg.campoObrigatorio}" >
										<f:selectItems value="#{setorMB.setorOpts}" />
										<rich:ajaxValidator event="onblur" />
									</rich:comboBox>
								</h:panelGroup>
													
							</h:panelGrid>
						</fieldset>
						<br />
		
						<h:panelGrid columns="2" width="100%" style="text-align:center;">
							<h:panelGroup>
								<a4j:commandButton value="#{msg.botaoSalvar}"
									action="#{salaMB.save}" reRender="idSalaMBForm, salaList"
									style="text-align:center;" />
								<rich:spacer width="15px" />
								<a4j:commandButton value="#{msg.botaoAtualizar}"
									action="#{salaMB.atualiza}" style="text-align:center;" reRender="idSalaMBForm, salaList, mensagens"/>
								<rich:spacer width="15px"/>
								<a4j:commandButton value="#{msg.botaoLimpar}"
									action="#{salaMB.limpar}" reRender="idSalaMBForm, salaList, mensagens"
									style="text-align:center;" />
							</h:panelGroup>
						</h:panelGrid>
					</h:form>
				</rich:tab>
				<rich:tab label="#{msg.salaPosicao}" switchType="client" disabled="#{salaMB.tabDesativada}" >
					<!-- TAB 2 Posicao -->
						<ui:include src="/admin/painelcontrole/posicaoSalaMBForm.xhtml" />
					<!-- TAB Posicao -->									
				</rich:tab>
				</rich:tabPanel>
			</p:panel>
		<br />
	    <h:form>
			<p:panel>
				<f:facet name="header">
					<h:outputText value="#{msg.salaListagem}" />
				</f:facet>
				<a4j:commandButton reRender="idSalaMBForm" value="#{msg.alterar}" action="#{salaMB.listaToFormSala}"/>
				<h:commandButton onclick="return confirm('Deseja excluir o registro?')" value="#{msg.excluir}" action="#{salaMB.remove}" reRender="salaList"/>
				<p:dataTable 
						id="salaList" 
						var="sala" 
						value="#{salaMB.salaList}" 
						paginator="true" 
						rows="6" 
						selection="#{salaMB.salaSelectedList}" 
						selectionMode="multiple">
					<p:column filterBy="#{sala.nome}" sortBy="#{sala.nome}" width="200">
						<f:facet name="header">
							<h:outputText value="#{msg.nome}" />
						</f:facet>
						<h:outputText value="#{sala.nome}" />
					</p:column>
					<p:column filterBy="#{sala.identificacao}" sortBy="#{sala.identificacao}" width="200">
						<f:facet name="header">
							<h:outputText value="#{msg.identificacao}" />
						</f:facet>
						<h:outputText value="#{sala.identificacao}" />
					</p:column>					
					<p:column filterBy="#{sala.setor.nome}" sortBy="#{sala.setor.nome}" width="200">
						<f:facet name="header">
							<h:outputText value="#{msg.setor}" />
						</f:facet>
						<h:outputText value="#{sala.setor.nome}" />
					</p:column>
				</p:dataTable>
				<h:outputText value="#{msg.exportarTodosDados}" style="font-weight:bold"/>:
				<h:commandLink>
					<p:graphicImage value="/images/excel.png" style="border:0;"/>
					<p:dataExporter type="xls" target="salaList" fileName="#{msg.sala}" />
				</h:commandLink>
				<h:commandLink>
					<p:graphicImage value="/images/pdf.png" style="border:0;"/>
					<p:dataExporter type="pdf" target="salaList" fileName="#{msg.sala}"/>
				</h:commandLink><rich:spacer width="10px"/>

				<h:outputText value="#{msg.exportarDadosPagina}" style="font-weight:bold"/>:
				<h:commandLink>
					<p:graphicImage value="/images/excel.png" style="border:0;"/>
					<p:dataExporter type="xls" target="salaList" fileName="#{msg.sala}" />
				</h:commandLink>
				<h:commandLink>
					<p:graphicImage value="/images/pdf.png" style="border:0;"/>
					<p:dataExporter type="pdf" target="salaList" fileName="#{msg.sala}"/>
				</h:commandLink>
			</p:panel>
		</h:form>
</ui:composition>